<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author markos
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */


/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author markos
 */
class Application_Model_AreaAcademica extends Application_Model_ModelAbstract
{

    /**
     * PK
     * Database var type int(10) unsigned
     *
     * @var int
     */
    protected $_CodigoAreaAcademica;

    /**
     * Quimica, HPC, astronomia.
     * Database var type varchar(100)
     *
     * @var string
     */
    protected $_Nombre;

    /**
     * Breve descripcion
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_Descripcion;

    /**
     * Codigo de account en cloudstack (UUID) asociado al area academica
     * Database var type varchar(40)
     *
     * @var string
     */
    protected $_AccountId;

    /**
     * Asociado al usuario alias del account representado por el area academica
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_ApiKey;

    /**
     * Asociado al usuario alias del account representado por el area academica
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_SecretKey;

    /**
     * Identificador para utilizar como username en cloudstack, debe ser unico.
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_UsernameAccount;

    /**
     * Database var type varchar(255)
     *
     * @var string
     */
    protected $_Password;


    /**
     * Parent relation area_academica_ibfk_1
     *
     * @var Application_Model_Usuario
     */
    protected $_Usuario;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'codigo_area_academica'=>'CodigoAreaAcademica',
            'nombre'=>'Nombre',
            'descripcion'=>'Descripcion',
            'account_id'=>'AccountId',
            'api_key'=>'ApiKey',
            'secret_key'=>'SecretKey',
            'username_account'=>'UsernameAccount',
            'password'=>'Password',
        ));

        $this->setParentList(array(
            'AreaAcademicaIbfk1'=> array(
                    'property' => 'Usuario',
                    'table_name' => 'Usuario',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column codigo_area_academica
     *
     * @param int $data
     * @return Application_Model_AreaAcademica
     */
    public function setCodigoAreaAcademica($data)
    {
        $this->_CodigoAreaAcademica = $data;
        return $this;
    }

    /**
     * Gets column codigo_area_academica
     *
     * @return int
     */
    public function getCodigoAreaAcademica()
    {
        return $this->_CodigoAreaAcademica;
    }

    /**
     * Sets column nombre
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setNombre($data)
    {
        $this->_Nombre = $data;
        return $this;
    }

    /**
     * Gets column nombre
     *
     * @return string
     */
    public function getNombre()
    {
        return $this->_Nombre;
    }

    /**
     * Sets column descripcion
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setDescripcion($data)
    {
        $this->_Descripcion = $data;
        return $this;
    }

    /**
     * Gets column descripcion
     *
     * @return string
     */
    public function getDescripcion()
    {
        return $this->_Descripcion;
    }

    /**
     * Sets column account_id
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setAccountId($data)
    {
        $this->_AccountId = $data;
        return $this;
    }

    /**
     * Gets column account_id
     *
     * @return string
     */
    public function getAccountId()
    {
        return $this->_AccountId;
    }

    /**
     * Sets column api_key
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setApiKey($data)
    {
        $this->_ApiKey = $data;
        return $this;
    }

    /**
     * Gets column api_key
     *
     * @return string
     */
    public function getApiKey()
    {
        return $this->_ApiKey;
    }

    /**
     * Sets column secret_key
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setSecretKey($data)
    {
        $this->_SecretKey = $data;
        return $this;
    }

    /**
     * Gets column secret_key
     *
     * @return string
     */
    public function getSecretKey()
    {
        return $this->_SecretKey;
    }

    /**
     * Sets column username_account
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setUsernameAccount($data)
    {
        $this->_UsernameAccount = $data;
        return $this;
    }

    /**
     * Gets column username_account
     *
     * @return string
     */
    public function getUsernameAccount()
    {
        return $this->_UsernameAccount;
    }

    /**
     * Sets column password
     *
     * @param string $data
     * @return Application_Model_AreaAcademica
     */
    public function setPassword($data)
    {
        $this->_Password = $data;
        return $this;
    }

    /**
     * Gets column password
     *
     * @return string
     */
    public function getPassword()
    {
        return $this->_Password;
    }

    /**
     * Sets parent relation UsernameAccount
     *
     * @param Application_Model_Usuario $data
     * @return Application_Model_AreaAcademica
     */
    public function setUsuario(Application_Model_Usuario $data)
    {
        $this->_Usuario = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['username'];
        }

        $this->setUsernameAccount($primary_key);

        return $this;
    }

    /**
     * Gets parent UsernameAccount
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Usuario
     */
    public function getUsuario($load = true)
    {
        if ($this->_Usuario === null && $load) {
            $this->getMapper()->loadRelated('AreaAcademicaIbfk1', $this);
        }

        return $this->_Usuario;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_AreaAcademica
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_AreaAcademica());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_AreaAcademica::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getCodigoAreaAcademica() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('codigo_area_academica = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getCodigoAreaAcademica()));
    }
}
